package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.DishFlavor;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;


public interface DishMapper {

    /**
     * 插入菜单
     * 
 * @param dish
     * @return 
     * @author heiheiheng
     * @create 2025/7/17
     **/
    @Options(useGeneratedKeys = true,keyProperty = "id") //获取主键值并赋值给id
    @Insert("insert into dish values (null,#{name},#{categoryId},#{price},#{image},#{description},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    @AutoFill(OperationType.INSERT)
    void insert(Dish dish) ;

    Page<DishVO> pageDishQuery(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 根据id查询
     * 
 * @param id
     * @return
     * @author heiheiheng
     * @create 2025/7/18
     **/
    Dish selectById(Long id);

    /**
     * 批量删除
     *
 * @param dishId
     * @return
     * @author heiheiheng
     * @create 2025/7/18
     **/
    void deleteBatch(List<Long> dishId);

    /**
     * 更新菜品
     * 
 * @param dish
     * @return 
     * @author heiheiheng
     * @create 2025/7/18
     **/
    @AutoFill(OperationType.UPDATE)
    void updateDish(Dish dish);

    /**
     * 根据id查询菜品
     *
 * @param categoryId
 * @param status
     * @return
     * @author heiheiheng
     * @create 2025/8/2
     **/
    ArrayList<Dish> getDishByCategoryId(Long categoryId,Integer status);

    /**
     * 根据分类id获取菜品
     * @param categoryId
     * @return
     */
    ArrayList<Dish> getByCategoryId(Long categoryId, Integer status);

    /**
     * 根据id查询菜品口味
     * 
 * @param id
     * @return 
     * @author heiheiheng
     * @create 2025/8/7
     **/
    ArrayList<DishFlavor> getFlavorById(Long id);

    /**
     * 查询套餐总览
     *
 * @param map
     * @return
     * @author heiheiheng
     * @create 2025/8/13
     **/
    Integer countByMap(Map map);
}
